package engine.display.newAttack
{
	import flash.display.MovieClip;
	
	import newx.com.ResManager;
	import newx.com.config.StaticIni;

	public class AttackSkillNameLogic
	{
		private static	 var _self	:	AttackSkillNameLogic;
		
		public static function getInstance():AttackSkillNameLogic
		{
			if ( _self == null )
			{
				_self = new AttackSkillNameLogic();
			}
			return _self;
		}
		
		private var _place			:	MovieClip;
		
		private var _playingSkillEffects : Array = [];
		
		private var _saveEffects : Array = [];
		
		public function AttackSkillNameLogic()
		{
			
		}
		
		public function setPlace( place : MovieClip ):void
		{
			_place = place;
		}
		
		private function getEffect():MovieClip
		{
			if( _saveEffects.length > 1 )
			{
				return _saveEffects.shift();	
			}
			return ResManager.newResClass("RoundEffect") as MovieClip;//ResManager.getResContentCopy( "RoundEffect" ) as MovieClip;
		}
		
		public function playSkillName( skill : String ):void
		{
			var effect : MovieClip = getEffect();
			effect.x = 569;
			effect.y = 280;
			_place.addChild( effect );
			
			effect.gotoAndPlay(1);
			effect["movie"].gotoAndPlay(1);
			effect["text"] = StaticIni.getSwfLangStr( skill );
			
			(effect["movie"] as MovieClip).addFrameScript( effect["movie"].totalFrames - 1, playOver );
			
			function playOver():void
			{
				effect["movie"].stop();
				effect.movie.movie1.num.x = -80;
				effect.movie.movie1.num.y = -15;
				
				_saveEffects.push( effect );
			}
				
			_playingSkillEffects.push( effect );
		}
	}
}